package com.gopay.common.cps.dao.check.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.check.OrderTranAcctDtlDAO;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * description ：订单状态检查 DAO 接口实现类
 * edit by ：lx
 * datetime ：2017/8/1517:29
 */
@Repository("orderTranAcctDtlDAO")
public class OrderTranAcctDtlDAOImpl extends BaseDAOImpl<Object[], Serializable> implements OrderTranAcctDtlDAO {
    @Override
    public List<Object[]> getListByGopayOrderId(String gopayOrderId) {
        Map<String, Object> map = new HashMap();
        StringBuffer sb = new StringBuffer();
        sb.append(" select distinct t.gopay_order_id, 1 ");
        sb.append(" from cps_gen_main_order t ");
        sb.append(" left join acps_acct_trans_dtl d ");
        sb.append(" on t.gopay_order_id = d.gopay_order_id ");
        sb.append(" where t.accounting_point = '1' and d.gopay_order_id is not null ");
        sb.append(" and t.gopay_order_id = :gopayOrderId ");
        sb.append(" and t.GOPAY_TXN_TM > (sysdate-180) ");//代码评审 增加时间限制 180 天
        map.put("gopayOrderId", gopayOrderId);
        return findBySql(sb.toString(), map);
    }
}
